package com.lkbaby.home.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lkbaby.home.dao.UserInfoDao;
import com.lkbaby.home.entity.UserInfo;
import com.lkbaby.home.service.UserInfoService;
import com.lkbaby.home.util.MD5Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户数据(UserInfo)服务接口实现层
 *
 * @author makejava
 * @since 2024-03-15 09:37:30
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {

	@Resource(type = UserInfoDao.class)
	private UserInfoDao userInfoDao;

	@Override
	public UserInfo checkLogin(UserInfo userInfo) {
		QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("userName", userInfo.getUserName());
		UserInfo userInfo1 = userInfoDao.selectOne(queryWrapper);

		if (MD5Utils.passwordIsTrue(userInfo.getUserPwd(), userInfo1.getUserPwd())) {
			return userInfo1;
		}
		return null;
	}
}

